<?php


namespace App\Console\Commands;


use App\Models\Ca\Customer;
use Illuminate\Console\Command;

class WorkTodayCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:workToday';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '生成今日任务';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $date = date('Y-m-d');
        //标记回访时间是今日的为今日任务
        Customer::query()->whereBetween('hf_time', [$date, $date . ' 23:59:59'])->update([
            'is_work_today' => 1
        ]);
        //标记未设置回访时间的客户
        $date = date('Y-m-d', strtotime('-3 day'));
        Customer::query()->whereBetween('created_at', [$date, $date . ' 23:59:59'])
            ->where('hf_time', '=', '')
            ->update([
                'is_work_today' => 1
            ]);
    }
}